package com.zprmb.udzt;

import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences.Editor;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;

import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.handmark.pulltorefresh.library.PullToRefreshBase.OnRefreshListener2;
import com.handmark.pulltorefresh.library.PullToRefreshScrollView;
import com.zprmb.udzt.ll.BaseHelper;
import com.zprmb.udzt.util.Constant;
import com.zprmb.udzt.util.LogUtils;
import com.zprmb.udzt.util.VolleryUtil;
import com.zprmb.udzt.view.FirstDialog;
import com.zprmb.udzt.view.FirstDialog.Scrollbottom;
import com.zprmb.udzt.view.SystemBarTintManager;

import org.json.JSONObject;

import java.text.DecimalFormat;

/**
 * 我的资产
 * @author shenshao
 */
public class AssetsActivity extends BaseActivity implements OnClickListener,OnRefreshListener2<ScrollView>{
	private TextView tv_total,tv_assets,tv_ltbamount,tv_regular,tv_accumulated_earnings,tv_available_Balance;
	private LinearLayout li_lj,li_my_red,li_my_exp,li_my_coupon;
	private PullToRefreshScrollView sv;
	private ImageView img_total;
	private Double allAssetDueInAfterAddInterest;
	private Button btn_recharge,btn_withdraw;
	private RelativeLayout rl_lincun,rl_licai,rl_my_reward,rl_liushui,rl_due,rl_due_money,rl_test,rl_regular_money_plus;
	private int first=1;
	private ImageView img_isbankcard;
	private RelativeLayout rl_my_invate;
	private TextView assets_red,assets_coupon,assets_exp,my_title;
	private TextView tv_customer,tv_due_regular,tv_day_reward;
	private boolean pay;
	private Double rmbAll,ltbAmount;
	private Double allAssetDueInPrincipal;  // 代收本金【定期理财】
	private Double allAssetDueInInterest;  // 代收利息【定期理财】
	private Double allAssetDueInAddInterest;  //  代收加息券利息【定期理财】
	private Double userRateCouponDueInterest2;// 代收加息券利息【定期】
	private Double allAssetReceivedInterest;//定期理财已收利息
	private Double allAssetReceivedAddInterest;//定期理财加息券已收收益
	private Double allAssetReceivedAfterAddInterest;//定期理财平台附加利息
	private Double allFixedInterest;//定期计划已收利息
	private Double totalRateRaisingRecInterest;//定期计划加息券已收收益
	private LinearLayout li_pass;
	private TextView test_status,tv_regular_plus;
	private String my_status;
	private ImageView img_nowork,img_pass;
	DecimalFormat df = new DecimalFormat("###0.00");
	DecimalFormat df2 = new DecimalFormat("###0");
	private boolean login;
	private TextView tv_login,tv_due_money;
	private String total_assets,keyong,frozen,ztdj,monthwin,lcb,fldj,txdj,current,fixrealdue,exedue,amount,userRateCouponDueInterest ;
    private String current_income,dingqi_income,sanbiao_income,red_income,coupon_income,commission_income,exe_income,interest,allFixedRealDueIn,rmbDueInAll;
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.assets_activity);
		
		BbtApplication.getInstance().addActvity(this);
//		Toast.makeText(this, "个人中心页面", Toast.LENGTH_SHORT).show();

		setImmersionStatus();
		assets_red=(TextView)findViewById(R.id.assets_red);
		assets_coupon=(TextView)findViewById(R.id.assets_coupon);
		assets_exp=(TextView)findViewById(R.id.assets_exp);
		tv_total=(TextView)findViewById(R.id.tv_total_assets);
		tv_assets=(TextView)findViewById(R.id.tv_assets);
		img_pass=(ImageView)findViewById(R.id.img_pass);
		test_status=(TextView)findViewById(R.id.test_status);
		my_title=(TextView)findViewById(R.id.my_title);
		tv_ltbamount=(TextView)findViewById(R.id.tv_ltbamount);
		tv_regular=(TextView)findViewById(R.id.tv_regular);
		li_pass=(LinearLayout)findViewById(R.id.li_pass);
		btn_recharge=(Button)findViewById(R.id.recharge);
		btn_withdraw=(Button)findViewById(R.id.withdraw);
		tv_regular_plus=(TextView)findViewById(R.id.tv_regular_plus);
		tv_day_reward=(TextView)findViewById(R.id.day_reward);
		rl_test=(RelativeLayout)findViewById(R.id.rl_my_test);
		sv=(PullToRefreshScrollView)findViewById(R.id.sv);
		tv_login=(TextView)findViewById(R.id.tv_login);
		img_isbankcard=(ImageView)findViewById(R.id.img_isbankcard);
		rl_my_invate=(RelativeLayout)findViewById(R.id.rl_my_invite);
		tv_accumulated_earnings=(TextView)findViewById(R.id.tv_accumulated_earnings);
		tv_available_Balance=(TextView)findViewById(R.id.available_Balance);	
		li_lj=(LinearLayout)findViewById(R.id.li_lj);
		li_my_red=(LinearLayout)findViewById(R.id.li_my_red);
		li_my_coupon=(LinearLayout)findViewById(R.id.li_my_coupon);
		li_my_exp=(LinearLayout)findViewById(R.id.li_my_exp);
		img_nowork=(ImageView)findViewById(R.id.iv_v4_nonetwork);
		img_total=(ImageView)findViewById(R.id.img_total_assets);
		rl_lincun=(RelativeLayout)findViewById(R.id.rl_my_lincun);
		rl_licai=(RelativeLayout)findViewById(R.id.rl_regular_money);
		rl_regular_money_plus=(RelativeLayout)findViewById(R.id.rl_regular_money_plus);
		rl_my_reward=(RelativeLayout)findViewById(R.id.rl_day_reward);
		rl_liushui=(RelativeLayout)findViewById(R.id.rl_funds_flow);
		tv_customer=(TextView)findViewById(R.id.enterprise_tel);
		rl_due=(RelativeLayout)findViewById(R.id.rl_due_money);
		tv_due_money=(TextView)findViewById(R.id.tv_due_regular);
		tv_due_regular=(TextView)findViewById(R.id.tv_due_regular);
		rl_due_money=(RelativeLayout)findViewById(R.id.rl_due_money);
		li_pass.setOnClickListener(this);
		img_pass.setOnClickListener(this);
		rl_regular_money_plus.setOnClickListener(this);
		rl_test.setOnClickListener(this);
		rl_my_invate.setOnClickListener(this);
		rl_due_money.setOnClickListener(this);
		tv_customer.setOnClickListener(this);
		tv_total.setOnClickListener(this);
		li_lj.setOnClickListener(this);
		li_my_coupon.setOnClickListener(this);
		li_my_red.setOnClickListener(this);
		li_my_exp.setOnClickListener(this);
		rl_lincun.setOnClickListener(this);
		rl_my_reward.setOnClickListener(this);
		rl_licai.setOnClickListener(this);
		rl_liushui.setOnClickListener(this);
		btn_recharge.setOnClickListener(this);
		btn_withdraw.setOnClickListener(this);
		sv.setOnRefreshListener(this);
		tv_login.setOnClickListener(this);
		tv_assets.setOnClickListener(this);
		sv.setVisibility(View.GONE);



		img_nowork.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
			 	// TODO Auto-generated method stub
			  initData(true);	
			}
		});
//		Test();
		initData(true);
		
	}
	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
		BbtApplication.getInstance().removeActvity(this);
	}
	private void setImmersionStatus() {
		if (VERSION.SDK_INT >= VERSION_CODES.KITKAT) {
			// 透明状态栏
			getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
			// 透明导航栏
			//getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
		}
	}
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		// TODO Auto-generated method stub
		return false;
	}
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		initData(false);
		if (getShare().getString("isAssetsFirst", "").equals("")) {
			getShare().edit().putString("isAssetsFirst", "1").commit();
			FirstDialog fd = new FirstDialog(this,3);
			fd.setscrollbottom(new Scrollbottom() {
				
				@Override
				public void tobottom() {
					// TODO Auto-generated method stub
					handler2.sendEmptyMessage(1);
				}
			});
			fd.show();
		}
		
	}
	Handler handler2=new Handler(){
		public void handleMessage(Message msg) {
			sv.getRefreshableView().fullScroll(ScrollView.FOCUS_DOWN);
		};
	};
	private void changeHide(){
		if(gethide()==1){
			tv_regular_plus.setText("*******");
			tv_regular.setText("*******");
//			Log.e("老定期", (json2.optDouble(("allFixedRealDueIn")+userRateCouponDueInterest2))+"");
			tv_due_regular.setText("*******");
			tv_assets.setText("*******");
			tv_accumulated_earnings.setText("*******");
			tv_available_Balance.setText("*******");
			tv_ltbamount.setText("*******");
			img_pass.setBackgroundResource(R.drawable.yan2);
		}else{
			tv_regular_plus.setText(df.format(allAssetDueInPrincipal+allAssetDueInInterest+allAssetDueInAddInterest+allAssetDueInAfterAddInterest)+"元");
			tv_regular.setText(df.format(Double.parseDouble(allFixedRealDueIn)+userRateCouponDueInterest2)+"元");
//			Log.e("老定期", (json2.optDouble(("allFixedRealDueIn")+userRateCouponDueInterest2))+"");
			tv_due_regular.setText(df.format(rmbAll)+"元");
			tv_assets.setText(df.format(Double.parseDouble(total_assets)));
			tv_accumulated_earnings.setText(df.format(Double.parseDouble(interest)));
			tv_available_Balance.setText(df.format(Double.parseDouble(keyong)));
			tv_ltbamount.setText(df.format(ltbAmount)+"元");
			img_pass.setBackgroundResource(R.drawable.yan1);
		}
	}
	private void initData(boolean isshow) {
		VolleryUtil vollery = new VolleryUtil() {
			public void onUpDate(JSONObject jsonObject) {
				LogUtils.e("ss", jsonObject.toString());
				if(jsonObject.optInt("success")==1){					
					Log.e("ferf", getdeviceId());
					login=true;
					sv.setVisibility(View.VISIBLE);
					img_nowork.setVisibility(View.GONE);
					JSONObject json1=jsonObject.optJSONObject("data");
					JSONObject json2=json1.optJSONObject("userFund");
					my_status=json1.optString("riskKey");
					test_status.setText(json1.optString("riskName"));
					if(json1.optBoolean("nameAuth")){
						my_title.setText(json1.optString("userName")+"的帐户");
					}else{
						my_title.setText(json1.optString("userMobile"));
					}  
					if(!json1.optString("availableGiftAmount").equals("")){
						
						assets_red.setText(df.format(json1.optDouble("availableGiftAmount"))+"元");
						assets_coupon.setText(df2.format(json1.optDouble("userRaisingrates"))+"张");
						assets_exp.setText(df.format(json1.optDouble("unUseExperience"))+"元");
					}
					if (!json1.optBoolean("isBindCard")) {
						img_isbankcard.setVisibility(View.VISIBLE);
						
					}else{
						img_isbankcard.setVisibility(View.GONE);
					}
					if(json1.optDouble("dailyRaffle")>0){
						tv_day_reward.setVisibility(View.VISIBLE);
						tv_day_reward.setText("您还有"+json1.optString("dailyRaffle")+"次抽奖机会");
					}else{
						tv_day_reward.setVisibility(View.GONE);
					}
					ztdj=json2.optString("rmbFrozen");
					frozen=json2.optString("frozen");
					monthwin=json2.optString("monthFrozen");
					fldj=json2.optString("recycleFrozen");
					txdj=json2.optString("withdrawFrozen");
					current=json2.optString("currentBalance");
					lcb=json2.optString("currentFrozen");
					fixrealdue=json2.optString("fixedRealDueIn");
					exedue=json2.optString("totalExeDueInterest");
					total_assets=json2.optString("amount");
					keyong=json1.optString("availableAmount");
					current_income=json2.optString("currentInterest");
					dingqi_income=json2.optString("allFixedInterest");
					sanbiao_income=json2.optString("rmbInterest");
					red_income=json2.optString("platformRedPackage");
					commission_income=json2.optString("platformReward");
					exe_income=json2.optString("totalExeRecInterest");
					interest=json2.optString("interest");					
					allAssetReceivedInterest=json2.optDouble("allAssetReceivedInterest");//定期理财已收利息
					allAssetReceivedAddInterest=json2.optDouble("allAssetReceivedAddInterest");//定期理财加息券已收收益
					allAssetReceivedAfterAddInterest=json2.optDouble("allAssetReceivedAfterAddInterest");//定期理财平台附加利息
					allFixedInterest=json2.optDouble("allFixedInterest");//定期计划已收利息
					totalRateRaisingRecInterest=json2.optDouble("totalRateRaisingRecInterest");//定期计划加息券已收收益
					allAssetDueInPrincipal=json2.optDouble("allAssetDueInPrincipal");
					allAssetDueInInterest =json2.optDouble("allAssetDueInInterest");
					allAssetDueInAddInterest=json2.optDouble("allAssetDueInAddInterest");
					allFixedRealDueIn=json2.optString("allFixedRealDueInWithoutRaising");
					userRateCouponDueInterest2=json2.optDouble("userRateCouponDueInterest");
					rmbDueInAll=json2.optString("rmbDueInAll");
					rmbAll=json2.optDouble("rmbAll");
					allAssetDueInAfterAddInterest=json2.optDouble("allAssetDueInAfterAddInterest");
					coupon_income=json2.optString("totalRateRaisingRecInterest");
					userRateCouponDueInterest=json2.optString("userRateCouponDueInterest");
					ltbAmount=json1.optDouble("ltbAmount");
					tv_regular_plus.setText(df.format(allAssetDueInPrincipal+allAssetDueInInterest+allAssetDueInAddInterest+allAssetDueInAfterAddInterest)+"元");
					tv_regular.setText(df.format(json2.optDouble("allFixedRealDueIn")+userRateCouponDueInterest2)+"元");
//					Log.e("老定期", (json2.optDouble(("allFixedRealDueIn")+userRateCouponDueInterest2))+"");
					tv_due_regular.setText(df.format(Double.parseDouble(json2.optString("rmbAll")))+"元");
					tv_assets.setText(df.format(Double.parseDouble(json2.optString("amount"))));
					tv_accumulated_earnings.setText(df.format(Double.parseDouble(json2.optString("interest"))));
					tv_available_Balance.setText(df.format(Double.parseDouble(json1.optString("availableAmount"))));
					tv_ltbamount.setText(df.format(Double.parseDouble(json1.optString("ltbAmount")))+"元");
					pay=json1.optBoolean("payPass");
					changeHide();
				}else { 
					
					if (jsonObject.optString("comment").equals("please login")) {
						
						login=false;
						if(getShare().getInt("top", 0)==1){
							Editor editor = getShare().edit();							
							editor.putInt("top", 0);
							editor.commit();
						}else{
							
						
						if(getShare().getString("mobile", "").equals("")){
							Intent intent = new Intent(AssetsActivity.this,Log_or_RegisActivity.class);
							intent.putExtra("who", 4);
							startActivity(intent);
							
						}else{
//							if(getShare().getInt("login", 0)==1){
//								Editor editor = getShare().edit();							
//								editor.putInt("login", 0);
//								editor.commit();
//								return;
//							}
							Log.e("未登录", "未登录");
							Intent intent = new Intent(AssetsActivity.this,LoginActivity.class);
							intent.putExtra("who", 4);
							startActivity(intent);							
						}
						}
					}else{
						Toast.makeText(AssetsActivity.this, jsonObject.optString("comment"), 2000).show();
						
					}
				}
				
				
			}
			public void onError() {
				Toast.makeText(AssetsActivity.this, "请求失败   请检查网络设置", 2000).show();
				sv.setVisibility(View.GONE);
				img_nowork.setVisibility(View.VISIBLE);
				
			}
		};
		vollery.setRequestMethod(0);
		vollery.setHeaders("token", getToken());
		vollery.setShow(isshow);
		vollery.execute(this, Constant.URL+"/api/v5/user/userInfo","");
		
	}

	public static void initSystemBar(Activity activity) {
		if (VERSION.SDK_INT >= VERSION_CODES.KITKAT) {
			setTranslucentStatus(activity, true);
		}
		SystemBarTintManager tintManager = new SystemBarTintManager(activity);
		tintManager.setStatusBarTintEnabled(true);
		//使用颜色资源
		//tintManager.setNavigationBarTintResource(R.color.hongse);
		//tintManager.setTintColor(activity.getResources().getColor(R.color.huangse));
		//tintManager.setStatusBarTintResource(R.color.black);
	}
	@TargetApi(19)
	private static void setTranslucentStatus(Activity activity, boolean on) {
		Window win = activity.getWindow();
		WindowManager.LayoutParams winParams = win.getAttributes();
		final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
		if (on) {
			winParams.flags |= bits;
		} else {
			winParams.flags &= ~bits;
		}
		win.setAttributes(winParams);
	}

	@Override
	public void onClick(View arg0) {
		// TODO Auto-generated method stub
		Intent intent=null;
		switch(arg0.getId()){
		case R.id.tv_total_assets:
			if(!login){
				Toast.makeText(AssetsActivity.this, "请先登录", 2000).show();
				return;
			}
			
			 intent=new Intent(AssetsActivity.this,Total_assets_Detail.class);
			 intent.putExtra("frozen",frozen);
			 intent.putExtra("ztdj",ztdj);
			 intent.putExtra("monthwin",monthwin);
			 intent.putExtra("allAssetDueInInterest",allAssetDueInInterest);
			 intent.putExtra("allAssetDueInPrincipal",allAssetDueInPrincipal);
			 intent.putExtra("allAssetDueInAddInterest",allAssetDueInAddInterest);
			 intent.putExtra("allAssetDueInAfterAddInterest",allAssetDueInAfterAddInterest);
			 intent.putExtra("lcb",lcb);
			 intent.putExtra("fldj",fldj);
			 intent.putExtra("txdj",txdj);
			 intent.putExtra("current",current);
			 intent.putExtra("exedue",exedue);
			 intent.putExtra("total_assets",total_assets);
			 intent.putExtra("allFixedRealDueIn",allFixedRealDueIn);
			 intent.putExtra("rmbDueInAll",rmbDueInAll);
			 intent.putExtra("keyong",keyong);
			 intent.putExtra("userRateCouponDueInterest",userRateCouponDueInterest);
			  
			startActivity(intent);
			break;
		case R.id.li_lj:
			if(!login){
				Toast.makeText(AssetsActivity.this, "请先登录", 2000).show();
				return;
			}
			 
			 intent=new Intent(AssetsActivity.this,Accumulated_earnings.class);
			 intent.putExtra("current", current_income);
			 intent.putExtra("dingqi", dingqi_income);
			 intent.putExtra("red", red_income);
			 intent.putExtra("yongjin", commission_income);
			 intent.putExtra("exe", exe_income);
			 intent.putExtra("san", sanbiao_income);
			 intent.putExtra("coupon", coupon_income);
			 intent.putExtra("interest", interest);
			 intent.putExtra("allAssetReceivedInterest", allAssetReceivedInterest);
			 intent.putExtra("allAssetReceivedAddInterest", allAssetReceivedAddInterest);
			 intent.putExtra("allAssetReceivedAfterAddInterest", allAssetReceivedAfterAddInterest);
			 intent.putExtra("allFixedInterest", allFixedInterest);
			 intent.putExtra("totalRateRaisingRecInterest", totalRateRaisingRecInterest);
			 
			startActivity(intent);
			break;
		case R.id.rl_my_lincun:
			 intent=new Intent(AssetsActivity.this,V6MineDexterityActivity.class);
			startActivity(intent);
			break;
		case R.id.rl_day_reward:
			
				intent=new Intent(AssetsActivity.this,V4WebViewActivity.class);
				intent.putExtra("url", "/h5/mLotteryDraw"+"?app=true");
				intent.putExtra("title", "每日抽奖");
				startActivity(intent);
			
//			getShare().edit().putString("isAssetsFirst", "").commit();
			break;
		case R.id.rl_funds_flow:
			 intent=new Intent(AssetsActivity.this,Funds_flow.class);
			startActivity(intent);		  
			break;
		case R.id.tv_assets:
			if(!login){
				Toast.makeText(AssetsActivity.this, "请先登录", 2000).show();
				return;
			}
			
			 intent=new Intent(AssetsActivity.this,Total_assets_Detail.class);
			 intent.putExtra("frozen",frozen);
			 intent.putExtra("ztdj",ztdj);
			 intent.putExtra("monthwin",monthwin);
			 intent.putExtra("allAssetDueInInterest",allAssetDueInInterest);
			 intent.putExtra("allAssetDueInPrincipal",allAssetDueInPrincipal);
			 intent.putExtra("allAssetDueInAddInterest",allAssetDueInAddInterest);
			 intent.putExtra("allAssetDueInAfterAddInterest",allAssetDueInAfterAddInterest);
			 intent.putExtra("lcb",lcb);
			 intent.putExtra("fldj",fldj);
			 intent.putExtra("txdj",txdj);
			 intent.putExtra("current",current);
			 intent.putExtra("exedue",exedue);
			 intent.putExtra("total_assets",total_assets);
			 intent.putExtra("allFixedRealDueIn",allFixedRealDueIn);
			 intent.putExtra("rmbDueInAll",rmbDueInAll);
			 intent.putExtra("keyong",keyong);
			 intent.putExtra("userRateCouponDueInterest",userRateCouponDueInterest);
			  
			startActivity(intent);
			break;
		case R.id.recharge:
			if(!login){
				Toast.makeText(AssetsActivity.this, "请先登录", 2000).show();
				return;
			}
			verifuser("1");
			break;
		case R.id.li_pass:
			if(gethide()==0){
				Editor ed=getShare().edit();
				ed.putInt("hide", 1);
				ed.commit();
				changeHide();
			}else{
				Editor ed=getShare().edit();
				ed.putInt("hide", 0);
				ed.commit();
				changeHide();
			}
			break;
		case R.id.withdraw:
			if(!login){
				Toast.makeText(AssetsActivity.this, "请先登录", 2000).show();
				return;
			}
			verifuser("2");
			break;
		case R.id.rl_regular_money:
			if(!login){
				Toast.makeText(AssetsActivity.this, "请先登录", 2000).show();
				return;
			}
			intent=new Intent(AssetsActivity.this,Regular_money.class);
			startActivity(intent);
			break;
		case R.id.enterprise_tel:
			BaseHelper.showDialog2(this, "拨号", "400-0101-016", 1);
			break;
		case R.id.rl_due_money:
			intent=new Intent(AssetsActivity.this,Regular_money2.class);
			startActivity(intent);
			break;  
		case R.id.rl_my_test:
			Intent intent0=null;
			if(my_status!=null){
				
			
			if(my_status.equals("NOTHING")){
				intent0=new Intent(AssetsActivity.this,WebViewActivity.class);
				intent0.putExtra("url", "/h5/assess/index?"+"?app=true&token=");
				
//				intent2.putExtra("url", "/h5/messageCenter?app=true&token="+getToken());
				
				intent0.putExtra("title", "风险测评");
				startActivity(intent0);
				
			}else{
				intent0=new Intent(AssetsActivity.this,WebViewActivity.class);
				intent0.putExtra("url", "/h5/assess/result?"+"?app=true&token=");
				
//				intent2.putExtra("url", "/h5/messageCenter?app=true&token="+getToken());
				
				intent0.putExtra("title", "风险测评");
				startActivity(intent0);
				
			}
			}
			break;
		case R.id.rl_my_invite:
			 intent=new Intent(AssetsActivity.this,My_invate.class);
			 startActivity(intent);
			break;
		
	case R.id.rl_regular_money_plus:
		intent=new Intent(AssetsActivity.this,Regular_money_new.class);
		 startActivity(intent);
		break;
	case R.id.li_my_coupon:
		intent=new Intent(AssetsActivity.this,MyCoupon.class);
		 startActivity(intent);
		break;
	case R.id.li_my_red:
		intent=new Intent(AssetsActivity.this,MyHongBao.class);
		 startActivity(intent);
		break;
	case R.id.li_my_exp:
		intent=new Intent(AssetsActivity.this,MyExperienceGold.class);
		 startActivity(intent);
		break;
	case R.id.img_pass:
		if(gethide()==0){
			Editor ed=getShare().edit();
			ed.putInt("hide", 1);
			ed.commit();
			changeHide();
		}else{
			Editor ed=getShare().edit();
			ed.putInt("hide", 0);
			ed.commit();
			changeHide();
		}
		
		break;
	}
		
		
	}
	Handler handler=new Handler(){
		public void handleMessage(Message msg) {
			
			if(msg.what==1){
				initData(true);
			}else{
				
				
				
			}
			
			sv.onRefreshComplete();
		};
	};
	@Override
	public void onPullDownToRefresh(PullToRefreshBase<ScrollView> refreshView) {
		// TODO Auto-generated method stub
		handler.sendEmptyMessage(1);
	}

	@Override
	public void onPullUpToRefresh(PullToRefreshBase<ScrollView> refreshView) {
		// TODO Auto-generated method stub
		
	}
	private void verifuser(final String who){
		VolleryUtil volleryUtil=new VolleryUtil() {
			
			@Override
			public void onUpDate(JSONObject jsonObject) {
				// TODO Auto-generated method stub
				if (jsonObject.optInt("success")==1) {
					JSONObject json = jsonObject.optJSONObject("data");
					Log.e("信息", jsonObject.toString());
					if (json.optBoolean("nameAuth")&&json.optBoolean("isBindCard")) {
						if (who.equals("1")) {
//							
							Intent intent = new Intent(AssetsActivity.this, V4AddMoneySActiviy.class);
							startActivity(intent);
						}else {
							if(pay){
								
								Intent intent = new Intent(AssetsActivity.this, V4UpMoneyActivity.class);
								startActivity(intent);
							}else{
								Intent intent = new Intent(AssetsActivity.this, Set_tr_pw.class);
								startActivity(intent);
							}
						}
					}else { 
						
//							if (!json.optBoolean("nameAuth")) {
//								Intent intent = new Intent(AssetsActivity.this,Real_Name.class);
//								startActivity(intent);
//								return;
//							}
						 if(json.optString("bankMobileStatus")!=null&&!json.optString("bankMobileStatus").equals("")&&json.optString("bankMobileStatus").equals("WAIT_CHECK")){
							 Intent intent = new Intent(AssetsActivity.this,BankCardActivity.class);
								intent.putExtra("bankcard", json.optString("cardNo"));
								intent.putExtra("isbank", 1);
								intent.putExtra("logourl", json.optString("logoUrl"));
								intent.putExtra("banknameEn", json.optString("bankNameEn"));
								intent.putExtra("banknameCn", json.optString("bankNameCn"));
								intent.putExtra("status", json.optString("bankMobileStatus"));
								startActivity(intent);
								return;
						 }
							if (!json.optBoolean("isBindCard")) {
//								!json.optBoolean("isBindCard")
								Intent intent = new Intent(AssetsActivity.this,BankCardActivity.class);
								intent.putExtra("who", 1);
								startActivity(intent);
								return;
							}
						
					}
				}else {
					if (jsonObject.optString("comment").equals("please login")) {
						Intent intent = new Intent(AssetsActivity.this,LoginActivity.class);
						startActivity(intent);
					}
				}
			}
			
			@Override
			public void onError() {
				// TODO Auto-generated method stub
				
			}
		};
		volleryUtil.setRequestMethod(0);
		volleryUtil.setHeaders("token", getToken());
		volleryUtil.setShow(true);
		volleryUtil.execute(this, Constant.URL+"/api/v5/user/userInfo","");
	}
	}
